<!-- HTML header for doxygen 1.8.3.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>AngelScript: Inheriting from application registered class</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="test/javascript" src="touch.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="aslogo_small.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">AngelScript
   </div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('doc_adv_inheritappclass.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Inheriting from application registered class </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>A script class cannot directly inherit from an application registered class, as the script classes are not compiled into native machine code like the application classes are.</p>
<p>It is however possible to emulate the inheritance by using a proxy class to hide the underlying differences in an abstract layer. The proxy class has two parts, one is the C++ side that the application sees, and the other is the script side that the scripts can see and inherit from.</p>
<p>The following is an example implementation of such a proxy class.</p>
<div class="fragment"><div class="line"><span class="comment">// On the C++ side</span></div>
<div class="line"><span class="keyword">class </span>FooScripted</div>
<div class="line">{</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line">  <span class="comment">// Public interface that we want the script to be able to override </span></div>
<div class="line">  <span class="keywordtype">void</span> CallMe()</div>
<div class="line">  {</div>
<div class="line">    <span class="comment">// If the script side is still alive, then call the scripted function</span></div>
<div class="line">    <span class="keywordflow">if</span>( !m_isDead-&gt;Get() )</div>
<div class="line">    {</div>
<div class="line">      <a class="code" href="classas_i_script_engine.html" title="The engine interface.">asIScriptEngine</a> *engine = m_obj-&gt;GetEngine();</div>
<div class="line">      <a class="code" href="classas_i_script_context.html" title="The interface to the virtual machine.">asIScriptContext</a> *ctx = engine-&gt;<a class="code" href="classas_i_script_engine.html#a32391ee83e58083b406ba068ab2ee049" title="Request a context.">RequestContext</a>();</div>
<div class="line"></div>
<div class="line">      <span class="comment">// GetMethodByDecl returns the virtual function on the script class</span></div>
<div class="line">      <span class="comment">// thus when calling it, the VM will execute the derived method</span></div>
<div class="line">      ctx-&gt;<a class="code" href="classas_i_script_context.html#a43976f42dfc6c1af23e132d36265173a" title="Prepares the context for execution of the function.">Prepare</a>(m_obj-&gt;GetObjectType()-&gt;GetMethodByDecl(<span class="stringliteral">&quot;void CallMe()&quot;</span>));</div>
<div class="line">      ctx-&gt;<a class="code" href="classas_i_script_context.html#a10d3c152b25d07584999f4d9fe5ce8b1" title="Sets the object for a class method call.">SetObject</a>(m_obj);</div>
<div class="line">      ctx-&gt;<a class="code" href="classas_i_script_context.html#a8e52894432737acac2e1a422e496bf84" title="Executes the prepared function.">Execute</a>();</div>
<div class="line"></div>
<div class="line">      engine-&gt;<a class="code" href="classas_i_script_engine.html#a22e42bf32902cbd6885731a6beeaca20" title="Return a context when it won&#39;t be used anymore.">ReturnContext</a>(ctx);</div>
<div class="line">    }</div>
<div class="line">  }</div>
<div class="line">  </div>
<div class="line">  <span class="keywordtype">int</span> m_value;</div>
<div class="line">   </div>
<div class="line">  <span class="comment">// A factory function that can be used by the script side to create</span></div>
<div class="line">  <span class="keyword">static</span> FooScripted *Factory()</div>
<div class="line">  {</div>
<div class="line">    <a class="code" href="classas_i_script_context.html" title="The interface to the virtual machine.">asIScriptContext</a> *ctx = <a class="code" href="angelscript_8h.html#ad3a20dc58093b92a5a44c7b6ada34a10" title="Returns the currently active context.">asGetActiveContext</a>();</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Get the function that is calling the factory so we can be certain it is the FooScript script class</span></div>
<div class="line">    <a class="code" href="classas_i_script_function.html" title="The interface for a script function description.">asIScriptFunction</a> *func = ctx-&gt;<a class="code" href="classas_i_script_context.html#a1c101300447f2909e5d188409a7180f6" title="Returns the function at the specified callstack level.">GetFunction</a>(0);</div>
<div class="line">    <span class="keywordflow">if</span>( func-&gt;<a class="code" href="classas_i_script_function.html#af930b362c37e5c4c117485d0bd4a34fb" title="Returns the object type for class or interface method.">GetObjectType</a>() == 0 || std::string(func-&gt;<a class="code" href="classas_i_script_function.html#af930b362c37e5c4c117485d0bd4a34fb" title="Returns the object type for class or interface method.">GetObjectType</a>()-&gt;<a class="code" href="classas_i_type_info.html#a49f83d3a9158331029324bfbe9ae46a8" title="Returns a temporary pointer to the name of the datatype.">GetName</a>()) != <span class="stringliteral">&quot;FooScripted&quot;</span> )</div>
<div class="line">    {</div>
<div class="line">      ctx-&gt;<a class="code" href="classas_i_script_context.html#a4ed608208cafdebe5676df079e27d392" title="Sets an exception, which aborts the execution.">SetException</a>(<span class="stringliteral">&quot;Invalid attempt to manually instantiate FooScript_t&quot;</span>);</div>
<div class="line">      <span class="keywordflow">return</span> 0;</div>
<div class="line">    }</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Get the this pointer from the calling function so the FooScript C++</span></div>
<div class="line">    <span class="comment">// class can be linked with the FooScript script class</span></div>
<div class="line">    <a class="code" href="classas_i_script_object.html" title="The interface for an instance of a script object.">asIScriptObject</a> *obj = <span class="keyword">reinterpret_cast&lt;</span><a class="code" href="classas_i_script_object.html" title="The interface for an instance of a script object.">asIScriptObject</a>*<span class="keyword">&gt;</span>(ctx-&gt;<a class="code" href="classas_i_script_context.html#a4f6761a7a0c872dda681d8e180830ff9" title="Returns a pointer to the object, if a class method is being executed.">GetThisPointer</a>(0));</div>
<div class="line"></div>
<div class="line">    <span class="keywordflow">return</span> <span class="keyword">new</span> FooScripted(obj);</div>
<div class="line">  }</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// Reference counting</span></div>
<div class="line">  <span class="keywordtype">void</span> AddRef() </div>
<div class="line">  { </div>
<div class="line">    m_refCount++; </div>
<div class="line"></div>
<div class="line">    <span class="comment">// Increment also the reference counter to the script side so </span></div>
<div class="line">    <span class="comment">// it isn&#39;t accidentally destroyed before the C++ side</span></div>
<div class="line">    <span class="keywordflow">if</span>( !m_isDead-&gt;Get() )</div>
<div class="line">      m_obj-&gt;AddRef();</div>
<div class="line">  }</div>
<div class="line">  <span class="keywordtype">void</span> Release() </div>
<div class="line">  { </div>
<div class="line">    <span class="comment">// Release the script instance too</span></div>
<div class="line">    <span class="keywordflow">if</span>( !m_isDead-&gt;Get() )</div>
<div class="line">      m_obj-&gt;Release();</div>
<div class="line"></div>
<div class="line">    <span class="keywordflow">if</span>( --m_refCount == 0 ) <span class="keyword">delete</span> <span class="keyword">this</span>; </div>
<div class="line">  }</div>
<div class="line"></div>
<div class="line"><span class="keyword">protected</span>:</div>
<div class="line"></div>
<div class="line">  <span class="comment">// The constructor and destructor are indirectly called</span></div>
<div class="line">  FooScripted(<a class="code" href="classas_i_script_object.html" title="The interface for an instance of a script object.">asIScriptObject</a> *obj) : m_obj(0), m_isDead(0), m_value(0), m_refCount(1)</div>
<div class="line">  {</div>
<div class="line">    <span class="comment">// Get the weak ref flag for the script object to </span></div>
<div class="line">    <span class="comment">// avoid holding a strong reference to the script class</span></div>
<div class="line">    m_isDead = obj-&gt;<a class="code" href="classas_i_script_object.html#a9ccca7fe3453219377fc9bd190bf7903" title="Returns the weak ref flag for the object.">GetWeakRefFlag</a>();</div>
<div class="line">    m_isDead-&gt;<a class="code" href="classas_i_lockable_shared_bool.html#a1183742552ce6b952cc3742bd456d787" title="Adds a reference to the shared boolean.">AddRef</a>();</div>
<div class="line"></div>
<div class="line">    m_obj = obj;</div>
<div class="line">  }</div>
<div class="line">  </div>
<div class="line">  ~FooScripted()</div>
<div class="line">  {</div>
<div class="line">    <span class="comment">// Release the weak ref flag</span></div>
<div class="line">    m_isDead-&gt;<a class="code" href="classas_i_script_object.html#a4bed3c3ac9f16294985835747aa122d3" title="Decrease reference counter.">Release</a>();</div>
<div class="line">  }</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// Reference count</span></div>
<div class="line">  <span class="keywordtype">int</span> m_refCount;</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// The C++ side holds a weak link to the script side to </span></div>
<div class="line">  <span class="comment">// avoid a circular reference between the C++ side and </span></div>
<div class="line">  <span class="comment">// script side</span></div>
<div class="line">  <a class="code" href="classas_i_lockable_shared_bool.html" title="A lockable shared boolean.">asILockableSharedBool</a> *m_isDead;</div>
<div class="line">  <a class="code" href="classas_i_script_object.html" title="The interface for an instance of a script object.">asIScriptObject</a> *m_obj;</div>
<div class="line">};</div>
</div><!-- fragment --><p>This type is registered with the engine as the following:</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> RegisterFooScripted(<a class="code" href="classas_i_script_engine.html" title="The engine interface.">asIScriptEngine</a> *engine)</div>
<div class="line">{</div>
<div class="line">  engine-&gt;<a class="code" href="classas_i_script_engine.html#a29c6c087c8c5b5cdb6271cfd161cc5a6" title="Registers a new object type.">RegisterObjectType</a>(<span class="stringliteral">&quot;FooScripted_t&quot;</span>, 0, <a class="code" href="angelscript_8h.html#a855d86fa9ee15b9f75e553ee376b5c7aa9450e038342b36c745858d2e5ae4b861" title="A reference type.">asOBJ_REF</a>);</div>
<div class="line">  engine-&gt;<a class="code" href="classas_i_script_engine.html#ad69bc821a7f1120369c1bd9526f41b9c" title="Registers a behaviour for the object type.">RegisterObjectBehaviour</a>(<span class="stringliteral">&quot;FooScripted_t&quot;</span>, <a class="code" href="angelscript_8h.html#a7e38df5b10ec8cbf2a688f1d114097c5a0b3db16eea35213b6f41f8d19dc1bd4c" title="Factory.">asBEHAVE_FACTORY</a>, <span class="stringliteral">&quot;FooScripted_t @f()&quot;</span>, <a class="code" href="angelscript_8h.html#a78f8f2c7f1c88b12e74a5ac47b4184ae" title="Returns an asSFuncPtr representing the function specified by the name.">asFUNCTION</a>(FooScripted::Factory), <a class="code" href="angelscript_8h.html#a3ec92ea3c4762e44c2df788ceccdd1e4a68ae43cc91cdfc3fa4590c9e6164e4f4" title="A cdecl function.">asCALL_CDECL</a>);</div>
<div class="line">  engine-&gt;<a class="code" href="classas_i_script_engine.html#ad69bc821a7f1120369c1bd9526f41b9c" title="Registers a behaviour for the object type.">RegisterObjectBehaviour</a>(<span class="stringliteral">&quot;FooScripted_t&quot;</span>, <a class="code" href="angelscript_8h.html#a7e38df5b10ec8cbf2a688f1d114097c5a1dfa5b72ad69a7bf70636d4fcb1b1d84" title="AddRef.">asBEHAVE_ADDREF</a>, <span class="stringliteral">&quot;void f()&quot;</span>, <a class="code" href="angelscript_8h.html#a7345e6b3afabec24efd0ff77886d49a6" title="Returns an asSFuncPtr representing the class method specified by class and method name...">asMETHOD</a>(FooScripted, AddRef), <a class="code" href="angelscript_8h.html#a3ec92ea3c4762e44c2df788ceccdd1e4aea516c8742acc1edff6a43dc1bb09e96" title="A thiscall class method.">asCALL_THISCALL</a>);</div>
<div class="line">  engine-&gt;<a class="code" href="classas_i_script_engine.html#ad69bc821a7f1120369c1bd9526f41b9c" title="Registers a behaviour for the object type.">RegisterObjectBehaviour</a>(<span class="stringliteral">&quot;FooScripted_t&quot;</span>, <a class="code" href="angelscript_8h.html#a7e38df5b10ec8cbf2a688f1d114097c5a7134ce13c81967191af401a1e5170a0c" title="Release.">asBEHAVE_RELEASE</a>, <span class="stringliteral">&quot;void f()&quot;</span>, <a class="code" href="angelscript_8h.html#a7345e6b3afabec24efd0ff77886d49a6" title="Returns an asSFuncPtr representing the class method specified by class and method name...">asMETHOD</a>(FooScripted, Release), <a class="code" href="angelscript_8h.html#a3ec92ea3c4762e44c2df788ceccdd1e4aea516c8742acc1edff6a43dc1bb09e96" title="A thiscall class method.">asCALL_THISCALL</a>);</div>
<div class="line">  engine-&gt;<a class="code" href="classas_i_script_engine.html#a1d42c5d9fd06a07da279f491f8901317" title="Registers a method for the object type.">RegisterObjectMethod</a>(<span class="stringliteral">&quot;FooScripted_t&quot;</span>, <span class="stringliteral">&quot;void CallMe()&quot;</span>, <a class="code" href="angelscript_8h.html#a7345e6b3afabec24efd0ff77886d49a6" title="Returns an asSFuncPtr representing the class method specified by class and method name...">asMETHOD</a>(FooScripted, CallMe), <a class="code" href="angelscript_8h.html#a3ec92ea3c4762e44c2df788ceccdd1e4aea516c8742acc1edff6a43dc1bb09e96" title="A thiscall class method.">asCALL_THISCALL</a>);</div>
<div class="line">  engine-&gt;<a class="code" href="classas_i_script_engine.html#a33f3cd249307f5f11120a395579410f6" title="Registers a property for the object type.">RegisterObjectProperty</a>(<span class="stringliteral">&quot;FooScripted_t&quot;</span>, <span class="stringliteral">&quot;int m_value&quot;</span>, <a class="code" href="angelscript_8h.html#a717eccea17214bc1eb64bb9789c4915a" title="Returns the offset of an attribute in a struct.">asOFFSET</a>(FooScripted, m_value));</div>
<div class="line">}</div>
</div><!-- fragment --><p>The script side is declared as <a class="el" href="doc_script_shared.html">shared</a> so it can be used in all script modules. It is also declared as <a class="el" href="doc_script_class_inheritance.html#doc_script_class_inheritance_2">abstract</a> so it cannot be instantiated by itself, only as a parent class of another script class.</p>
<p>This script section should preferably be included automatically by the application in all the modules that should be able to derive from the FooScripted class.</p>
<pre>
  // On the script side
  shared abstract class FooScripted
  {
    // Allow scripts to create instances
    FooScripted() 
    {
      // Create the C++ side of the proxy
      @m_obj = FooScripted_t();  
    }</pre><pre>    // The script side forwards the call to the C++ side
    void CallMe() { m_obj.CallMe(); }</pre><pre>    // The C++ side property is exposed to the script through accessors
    int m_value 
    {
      get { return m_obj.m_value; }
      set { m_obj.m_value = value; }
    }</pre><pre>    // The script class can be implicitly cast to the C++ type through the opImplCast method
    FooScripted_t @opImplCast() { return m_obj; }</pre><pre>    // Hold a reference to the C++ side of the proxy
    private FooScripted_t @m_obj;
  }
</pre><p>Now the scripts classes can derive from the FooScripted class and access the properties and methods of the parent class normally.</p>
<pre>
  // Implement a script class that derives from the application class
  class FooDerived : FooScripted
  {
    void CallMe()
    {
       m_value += 1;
    }
  }</pre><pre>  void main()
  {
    // When newly created the m_value is 0
    FooDerived d;
    assert( d.m_value == 0 );</pre><pre>    // When calling the method the m_value is incremented with 1
    d.CallMe(); 
    assert( d.m_value == 1 );
  }
</pre><p>It is of course also possible to create an instance of the scripted class from the application and access it through the FooScripted C++ proxy, thus making it transparent from the rest of the application that the implementation is actually in the script.</p>
<div class="fragment"><div class="line">FooScripted *CreateFooDerived(<a class="code" href="classas_i_script_engine.html" title="The engine interface.">asIScriptEngine</a> *engine)</div>
<div class="line">{</div>
<div class="line">  <span class="comment">// Create an instance of the FooDerived script class that inherits from the FooScripted C++ class</span></div>
<div class="line">  <a class="code" href="classas_i_script_object.html" title="The interface for an instance of a script object.">asIScriptObject</a> *obj = <span class="keyword">reinterpret_cast&lt;</span><a class="code" href="classas_i_script_object.html" title="The interface for an instance of a script object.">asIScriptObject</a>*<span class="keyword">&gt;</span>(engine-&gt;<a class="code" href="classas_i_script_engine.html#a3101479b4340bc16bb9acb8e8d554266" title="Creates an object defined by its type.">CreateScriptObject</a>(mod-&gt;GetTypeInfoByName(<span class="stringliteral">&quot;FooDerived&quot;</span>)));</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// Get the pointer to the C++ side of the FooScripted class</span></div>
<div class="line">  FooScripted *obj2 = *<span class="keyword">reinterpret_cast&lt;</span>FooScripted**<span class="keyword">&gt;</span>(obj-&gt;<a class="code" href="classas_i_script_object.html#a6a8a3c7d1e103e43923614b719e3cb3a" title="Returns a pointer to the property referenced by prop.">GetAddressOfProperty</a>(0));</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// Increase the reference count to the C++ object, as this is what will </span></div>
<div class="line">  <span class="comment">// be used to control the life time of the object from the application side </span></div>
<div class="line">  obj2-&gt;AddRef();</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// Release the reference to the script side</span></div>
<div class="line">  obj-&gt;<a class="code" href="classas_i_script_object.html#a4bed3c3ac9f16294985835747aa122d3" title="Decrease reference counter.">Release</a>();</div>
<div class="line"></div>
<div class="line">  <span class="keywordflow">return</span> obj2;</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> Foo(<a class="code" href="classas_i_script_engine.html" title="The engine interface.">asIScriptEngine</a> *engine)</div>
<div class="line">{</div>
<div class="line">  FooScripted *obj = CreateFooDerived(engine);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Once the object is created the application can access it normally through</span></div>
<div class="line">  <span class="comment">// the FooScripted pointer, without having to know that the implementation</span></div>
<div class="line">  <span class="comment">// is actually done in the script.</span></div>
<div class="line">  </div>
<div class="line">  <span class="comment">// When newly created the m_value is 0</span></div>
<div class="line">  assert( obj-&gt;m_value == 0 );</div>
<div class="line"></div>
<div class="line">  <span class="comment">// When calling the method the m_value is incremented with 1 by the script </span></div>
<div class="line">  obj-&gt;CallMe();</div>
<div class="line">  assert( obj-&gt;m_value == 1 );</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Release the object to destroy the instance (this will also destroy the script side)</span></div>
<div class="line">  obj-&gt;Release();</div>
<div class="line">}</div>
</div><!-- fragment --> </div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Sun Dec 18 2016 12:35:27 for AngelScript by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.3.1 </li>
  </ul>
</div>
</body>
</html>
